<template>
  <div class="top">
    <div class="left">
      <button class="left-btn" @click="$router.push('/home')">首页</button>
    </div>
    <div class="center">
      <span class="title">{{ title }}</span>
    </div>
    <div class="right">
      <button class="right-btn">统计分析</button>
      <span class="time">当前时间：{{ time }}</span>
    </div>
  </div>
</template>

<script setup lang="ts">
import moment from 'moment';
const title = computed(() => import.meta.env.VITE_APP_TITLE);
const time = ref(moment().format('YYYY年MM月DD日 hh:mm:ss'));
const timer = ref(0);
onMounted(() => {
  timer.value = setInterval(() => {
    time.value = moment().format('YYYY年MM月DD日 hh:mm:ss');
  }, 1000);
});
// 离开当前路由销毁定时器
onUnmounted(() => {
  clearTimeout(timer.value);
});
</script>

<style lang="scss" scoped>
.top {
  width: 100%;
  height: 40px;
  display: flex;

  .left {
    flex: 1.5;
    background: url('../../images/dataScreen-header-left-bg.png') no-repeat;
    background-size: cover;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    .left-btn {
      width: 150px;
      height: 40px;
      font-size: 25px;
      color: aqua;
      border: none;
      background: url('../../images/dataScreen-header-btn-bg-l.png') no-repeat;
      background-size: cover;
    }
  }
  .center {
    flex: 2;
    height: 74px;
    font-size: 30px;
    color: aqua;
    background: url('../../images/dataScreen-header-center-bg.png') no-repeat;
    background-size: 100% 100%;
    display: flex;
    justify-content: center;
    align-items: center;

    .title {
      font-size: 50px;
    }
  }
  .right {
    flex: 1.5;
    background: url('../../images/dataScreen-header-right-bg.png') no-repeat;
    background-size: cover;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .right-btn {
      width: 150px;
      height: 40px;
      font-size: 25px;
      color: aqua;
      border: none;
      background: url('../../images/dataScreen-header-btn-bg-l.png') no-repeat;
      background-size: cover;
    }
    .time {
      color: aqua;
      font-size: 20px;
    }
  }
}
</style>
